
{***********************************************************}
{                                                           }
{      Informix esql "blob.h"                               }
{                                                           }
{      Translated to Object Pascal by                       }
{      Copyright (c) 2001-2008 Luxena Software Company      }
{      http://www.luxena.com                                }
{      e-mail: support@luxena.com                           }
{                                                           }
{***********************************************************}

unit IfxBlob;

{$I lx.inc}

{$IFDEF VER140_OR_ABOVE}
  {$ALIGN 8}
{$ENDIF}

interface

uses
  IfxTypes;

const
  TB_FAMILY = (2 * SizeOf(Integer) + 5 * SizeOf(LongInt));
  TB_VOLUME = (2 * SizeOf(Integer) + 6 * SizeOf(LongInt));
  TB_FLAGS = (2 * SizeOf(Integer) + 7 * SizeOf(LongInt) + 3 * SizeOf(Integer));
  SIZTBLOB = (11 * SizeOf(LongInt) + 6 * SizeOf(Integer));

  // 'flags' definitions
  BLOBISNULL = $0001; // BLOB is NULL
  BLOBALIEN = $0002; // BLOB is ALIEN
  BL_BSBLOB = $0004; // blob is stored in blobspace
  BL_PNBLOB = $0008; // store in tablespace
  BL_DESCRIPTOR = $0010; // optical BLOB descriptor
  BL_CACHE = $0040; // blob reside in optical cache
  BL_FLUSH = $0080; // blob didn't fit in cache

{$IFDEF OPTICAL}
  BL_SUBBLOB = $0010; // store in Optical Subsystem
  BL_BLOBID = $0020; // transfer the tblob (blob id)
{$ENDIF}

  BL_LOCALBLOB = $0040; // "remote" blob is actually local

{$IFDEF CDR}
  BL_NOCHANGE = $0100; // blob unchanged after row update
{$ENDIF}

type

  //=================================
  //  Structure of the BlobLocation
  //=================================

  // blob definitions
  // tblob_t is the data that is stored in the tuple - it describes the blob
  // NOTE: tb_fd is expected to be the first member and TB_FLAGS gives offset
  //       to the tb_flags member.
  //

  tblob = record
    tb_fd: int2; // blob file descriptor	(must be first)
    tb_coloff: int2; // Blob column offset in row

    tb_tblspace: int4; // blob table space
    tb_start: int4; // starting byte
    tb_end: int4; // ending byte-0 for end of blob
    tb_size: int4; // Size of blob
    tb_addr: int4; // Starting Sector or BlobPage
    tb_family: int4; // Family ID
    tb_volume: int4; // Family Volume

    tb_medium: int2; // Medium - odd if removable
    tb_bstamp: int2; // first BlobPage Blob stamp
    tb_sockid: int2; // socket id of remote blob
    tb_flags: int2; // flags - see below

    tb_reserved1: int4; // used tb_sysid
    tb_reserved2: int4; // used tb_lockid
    tb_reserved3: int4; // used tb_threadid
    tb_reserved4: int4; // used as tb_label
  end;

  Ttblob = tblob;


  // this struture is used to pass "useful" information back to
  // the user.

  blobinfo = record
    bi_size: int4; // Size of blob
    bi_addr: int4; // Starting Sector or BlobPage
    bi_family: int4; // Family ID
    bi_volume: int4; // Family Volume
    bi_flags: int2; // flags
    bi_medium: int2; // Medium - odd if removable
  end;

  Tblobinfo = blobinfo;

(**

{$IFDEF OPTICAL}
  // for optical blobs, the system id (of the system where the blob was
  // created) is stored in the blob descriptor

  tb_sysid = tb_reserved1;
{$ENDIF}


  // for alien blobs a lock id for fragmented tables is required since only a
  // single fragment of the table is being opened

  tb_lockid = tb_reserved2;


  // used by PDQ to determine if the blob row was read by the same thread the
  // blob is being retrieved by

  tb_threadid = tb_reserved3;


  // for identifying the level of the blob. This filed is the partition
  // number of the labeld tablespace, which indicates the level of tuple blob.

  tb_label = tb_reserved4;

**)

implementation

end.